//p5266
/*
#include <iostream>
using namespace std;

const int maxsize = 100000;

class Student {
public:
	int score;
	string name;
};

class SList {
public:
	int addsl(string na, int sc);
	int deletesl(string na);
	Student display();
	int countsl();
	SList() : size(0) {}
	int resizes();
	Student sl[maxsize];
	int size;
};

int main()
{
	int m; cin >> m;
	SList so;
	for (int i = 0; i < m; i ++)
	{
		int n; string ss; int insertnum; //操作数 名字索引 插入数
		cin >> n;
		if (n == 1)
		{
			cin >> ss >> insertnum;
			int sig = so.addsl(ss, insertnum);
			if (sig == 0) cout << "OK" << endl;
			else cout << "Not found" << endl;
		}
			
		else if (n == 2)
		{
			cin >> ss;
			for (int i = 0; i < so.resizes(); i ++)
			{
				if (so.sl[i].name == ss)
				{
					cout << so.sl[i].score << endl;
					break;
				}
			}
		}
			
		else if (n == 3)
		{
			cin >> ss;
			int sig = so.deletesl(ss);
			if (sig == 0)
			{
				cout << "Deleted successfully" << endl;
			}
		}

		else if (n == 4)
		{
			cout << so.countsl() << endl;
		}
			
		else cout << "ERROR" << endl;
	}
	return 0;
}

int SList::addsl(string na, int sc)
{
	this->SList[this->size].name = na;
	this->SList[this->size].name = sc;
	this->size ++;
}

int SLite::deletesl(string na)
{
	for (int i = 0; i < this->size; i ++)
	{
		if (this->SList[i] == na)
		{

		}
	}
}
*/

#include<iostream>
#include<cstring>
#include<map>//要用map嘛......你懂的
using namespace std;
map <string,int> a;   //定义一个string（姓名）到int（分数）的map
int main()
{
    int n;
    cin >> n; //n条操作
    for (int i =1; i <= n; i ++){
    	int op; //操作种类1234
    	string name; //学生姓名
    	cin >> op; //输入操作种类
    	if (op != 4)  //如果不是操作4就输入学生名字
    	cin >> name;
    	switch (op){  //开始了！
    		case 1:  //操作1：加入或修改学生
    		int score;  //这个操作需要输入分数
    		cin >> score;
    		a[name] = score; //map的对应关系，把名字和分数对应起来
    		cout << "OK\n";   //根据题目要求输出OK
    		break;   //别忘了加break！！！
    		case 2: //操作2：查询学生
    		if (a.count(name)) //如果找得到
    		cout << a[name] << endl; //输出对应的分数
    		else cout << "Not found\n"; //否则"Not Found"
    		break;   //别忘了加break！！！
    		case 3:  //操作3：删除学生
    		if(a.count(name))
    		{ //如果找得到
    			a.erase(name); //那就删了它
				cout << "Deleted successfully\n"; //成功删除
    	    }
    		else cout << "Not found\n"; //否则"Not Found" 
    		break;  //别忘了加break！！！
    		case 4:  //操作4：学生人数
    		cout << a.size() << endl; //输出元素个数就好啦
		}
	}
	return 0;  //这个不用解释了吧
}


